]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
keyboard: Separate keyval action notification
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 30 Jan 2024 09:59:14 +0000 (10:59 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 29 Feb 2024 15:42:22 +0000 (16:42 +0100)
Add a distinct signal for keys defining a keyval to have it handled
via event emulation.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3162>

js/ui/keyboard.js

index fe9db59c77035f87588b2b8291c9585e19664d97..5ebe3f56a4c7f8c5f4dc26e14f67c2fdd4f47ed9 100644 (file)
@@ -223,6 +223,7 @@ const Key = GObject.registerClass({
         'long-press': {},
         'pressed': {},
         'released': {},
+        'keyval': {param_types: [GObject.TYPE_UINT]},
         'commit': {param_types: [GObject.TYPE_UINT, GObject.TYPE_STRING]},
     },
 }, class Key extends St.BoxLayout {
@@ -316,15 +317,16 @@ const Key = GObject.registerClass({
             this._pressTimeoutId = 0;
         }
 
-        let keyval;
-        if (button === this.keyButton)
-            keyval = this._keyval;
-        if (!keyval && commitString)
-            keyval = this._getKeyvalFromString(commitString);
-        console.assert(keyval !== undefined, 'Need keyval or commitString');
-
-        if (this._pressed && (commitString || keyval))
-            this.emit('commit', keyval, commitString || '');
+        if (this._pressed) {
+            if (this._keyval && button === this.keyButton)
+                this.emit('keyval', this._keyval);
+            else if (commitString) {
+                const keyval = this._getKeyvalFromString(commitString);
+                this.emit('commit', keyval, commitString);
+            } else {
+                console.error('Need keyval or commitString');
+            }
+        }
 
         this.emit('released');
         this._hideSubkeys();
@@ -1437,6 +1439,13 @@ export const Keyboard = GObject.registerClass({
                 keyval: key.keyval,
             }, strings);
 
+            if (key.keyval) {
+                button.connect('keyval', (_actor, keyval) => {
+                    this._keyboardController.keyvalPress(keyval);
+                    this._keyboardController.keyvalRelease(keyval);
+                });
+            }
+
             if (key.action !== 'modifier') {
                 button.connect('commit', (_actor, keyval, str) => {
                     this._commitAction(keyval, str).then(() => {